#pragma once

#include "../QBase.h"
#include "../QSize.h"

#pragma warning(disable : 26812)

QNamespaceStart(Qui)

class QBaseObject
{
	private:
		int object_id = 0;
};

// Base draw cell
class QDrawCellBase
	: public  QSize,
	  private QBaseObject
{
	protected:
		QDrawCellBase* children_cell;

		IMAGE          background;

	protected:
		qsize_t        control_id = 0;

	private:
		COLORREF  current_line_color;
		COLORREF  current_fill_color;
		LINESTYLE current_line_style;
		FILLSTYLE current_fill_style;

		COLORREF  cell_line_color;
		COLORREF  cell_fill_color;
		LINESTYLE cell_line_style;
		FILLSTYLE cell_fill_style;

	private:
		virtual void _init_cell_attribute()
		{
			get_now_attribute();

			cell_line_color = current_line_color;
			cell_fill_color = current_line_color;
			cell_line_style = current_line_style;
			cell_fill_style = current_fill_style;
		}

	public:
		QDrawCellBase() { _init_cell_attribute();  children_cell = nullptr; }
		QDrawCellBase(QDrawCellBase* object) { _init_cell_attribute();  children_cell = object->children_cell; }

		virtual void   draw() {  };
		
		virtual void   get_now_attribute()
		{
			current_line_color = getlinecolor();
			current_fill_color = getfillcolor();
			
			getlinestyle(&current_line_style);
			getfillstyle(&current_fill_style);
		}
		virtual void   appy_attribute()
		{
			setbkmode(TRANSPARENT);

			setlinecolor(cell_line_color);
			setfillcolor(cell_fill_color);

			setfillstyle(&cell_fill_style);
			setlinestyle(&cell_line_style);
		}
		virtual void   restore_attribute()
		{
			setlinecolor(current_line_color);
			setfillcolor(current_fill_color);

			setfillstyle(&current_fill_style);
			setlinestyle(&current_line_style);
		}

		void           set_line_color(COLORREF new_line_color)
		{
			cell_line_color = new_line_color;
		}
		void           set_fill_color(COLORREF new_fill_color)
		{
			cell_fill_color = new_fill_color;
		}
		void		   set_fill_style(FILLSTYLE new_fill_style)
		{
			cell_fill_style = new_fill_style;
		}
		void		   set_line_style(LINESTYLE new_line_style)
		{
			cell_line_style = new_line_style;
		}

		COLORREF	   get_line_color() { return cell_line_color; }
		COLORREF       get_fill_color() { return cell_fill_color; }
		LINESTYLE      get_line_stlye() { return cell_line_style; }
		FILLSTYLE      get_fill_style() { return cell_fill_style; }

		void		   set_child_cell(QDrawCellBase* cell);
		QDrawCellBase* get_child_cell();

		QSize_t        get_position();
};

QNamespaceEnd
